﻿using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Cofe.Core.Property;

namespace Cofe.Core.Tasks
{
    public class TaskConstructor : ITaskConstructor
    {
        private TaskCreationOptions getCreationOption(object property)
        {
            return TaskCreationOptions.None;
        }

        public Task CreateTask(IPropertyHost propertyHost, object property, Action<object> action, CancellationToken cancelToken)
        {
            return new Task(action, property, cancelToken, getCreationOption(property));                
        }

        public Task<T> CreateTask<T>(IPropertyHost propertyHost, object property, Func<object, T> func, CancellationToken cancelToken)
        {
            return new Task<T>(func, propertyHost, cancelToken, getCreationOption(property));
        }

        public Task CreateTask(IPropertyHost propertyHost, object property, Action<object> action)
        {
            return CreateTask(propertyHost, property, action, CancellationToken.None);
        }

        public Task<T> CreateTask<T>(IPropertyHost propertyHost, object property, Func<object, T> func)
        {
            return CreateTask<T>(propertyHost, property, func, CancellationToken.None);
        }
    }
}
